<?php

namespace App\Http\Middleware;

use Closure;
use Dcat\Admin\Admin;
use Dcat\Admin\Models\Administrator as AdministratorModel;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Hash;


class CheckDefaultPassword
{
    public function handle(Request $request, Closure $next)
    {
        if (config('app.env') == 'production' && Hash::check(config('admin.default_password'), Admin::user()->password)) {
            //强制修改密码
            $url = '/' . config('admin.route.prefix') . '/auth/setting';
            return redirect($url);
        }
        return $next($request);
    }
}
